package haut.data;

import haut.system.member.events.SportingEvents;
import haut.system.member.person.*;
import haut.util.DuplicateCheck;
import haut.util.exception.DuplicationException;
import java.util.Vector;

/**
 * 系统数据类，
 * 只能被实例化一次，
 * 系统运行依赖这个类的实例。
 * @author MingJie Li
 */

public class SystemData {

    private static SystemData systemData = new SystemData();

    /**
     * 所有项目
     */
    private Vector<SportingEvents> allEvents = new Vector<SportingEvents>();

    /**
     * 所有运动员
     */
    private Vector<Player> allPlayer = new Vector<Player>();

    /**
     * 所有裁判员
     */
    private Vector<Judge> allJudges = new Vector<Judge>();

    /**
     * 所有志愿者
     */
    private Vector<Volunteer> allVolunteers = new Vector<Volunteer>();

    private SystemData() {}

    /**
     * 返回系统数据类的实例
     * @return {SystemData}
     * */
    public static SystemData getInstance() {
        return systemData;
    }

    /**
     * 得到当前所有项目
     * @return {Vector} allEvents
     * */
    public Vector<SportingEvents> getAllEvents() {
        return allEvents;
    }

    /**
     *  新增项目
     * @param event
     */
    public void addAllEvent(SportingEvents event) throws DuplicationException {
        DuplicateCheck.eventCheck(allEvents, event);
        allEvents.add(event);
    }

    /**
     * 得到当前所有运动员
     * @return {Vector} allPlayer
     */
    public Vector<Player> getAllPlayer() {
        return allPlayer;
    }

    /**
     * 新增运动员
     * @param player
     */
    public void addAllPlayer(Player player) throws DuplicationException {
        DuplicateCheck.playerCheck(allPlayer, player);
        allPlayer.add(player);
    }

    /**
     * 得到当前所有裁判员
     * @return {Vector} allJudge
     */
    public Vector<Judge> getAllJudges() {
        return allJudges;
    }

    /**
     * 新增裁判员
     * @param judge
     */
    public void addAllJudge(Judge judge) throws DuplicationException {
        DuplicateCheck.judgeCheck(allJudges, judge);
        allJudges.add(judge);
    }

    /**
     * 得到当前所有志愿者
     * @return {Vector} allVolunteer
     */
    public Vector<Volunteer> getAllVolunteer() {
        return allVolunteers;
    }

    /**
     * 新增志愿者
     * @param volunteer
     */
    public void addAllVolunteer(Volunteer volunteer) throws DuplicationException {
        DuplicateCheck.volunteerCheck(allVolunteers, volunteer);
        allVolunteers.add(volunteer);
    }
}
